home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CD ROM Paradise Collection 4
/
CD ROM Paradise Collection 4 1995 Nov.iso
/
program
/
swagg_m.zip
/
MATH.SWG
/
0010_PERMUTA1.PAS.pas
< prev
next >
Wrap
Pascal/Delphi Source File
|
1993-05-28
|
891b
|
39 lines
{
> Does anyone have an idea to perform permutations With pascal 7.0 ?
> As an example finding the number of 5 card hands from a total of 52 cards.
> Any help would be greatly appreciated.
This Program should work fine. I tested it a few times and it seemed to work.
It lets you call the Functions For permutation and combination just as you
would Write them: P(n,r) and C(n,r).
}
{$E+,N+}
Program CombPerm;
Var
Result:Extended;
Function Factorial(Num: Integer): Extended;
Var
Counter: Integer;
Total: Extended;
begin
Total:=1;
For Counter:=2 to Num do
Total:=Total * Counter;
Factorial:=Total;
end;
Function P(N: Integer; R: Integer): Extended;
begin
P:=Factorial(N)/Factorial(N-R);
end;
Function C(N: Integer; R: Integer): Extended;
begin
C:=Factorial(N)/(Factorial(N-R)*Factorial(R));
end;
begin
Writeln(P(52,5));
end.